#include"BinarySearchTree.h"


void test1()
{
	int a[] = { 8, 3, 1, 10, 6, 4, 7, 14, 13 };
	BSTree<int> bs;
	for (auto e : a)
	{
		bs.insert(e);
	}
	bs.InOrder();

	cout << bs.Find(8) << endl;

	cout << bs.Find(1) << endl;

	cout << bs.Find(13) << endl;

	cout << bs.Find(20) << endl;

	bs.Erase(8);
	bs.InOrder();
	bs.insert(8);

	bs.Erase(3);
	bs.InOrder();
	bs.insert(3);

	bs.Erase(12);
	bs.InOrder();
	bs.insert(12);

	for (auto e : a)
	{
		bs.Erase(e);
	}
	bs.InOrder();
}

void test2()
{
	int a[] = { 8, 3, 1, 10, 6, 4, 7, 14, 13 };
	BSTree<int> bs;
	for (auto e : a)
	{
		bs.InsertR(e);
	}
	bs.InOrder();
	cout << bs.FindR(8) << endl;

	cout << bs.FindR(1) << endl;

	cout << bs.FindR(13) << endl;

	cout << bs.FindR(20) << endl;

	bs.EraseR(8);
	bs.InOrder();
	bs.insert(8);

	bs.EraseR(3);
	bs.InOrder();
	bs.insert(3);

	bs.EraseR(12);
	bs.InOrder();
	bs.insert(12);

	for (auto e : a)
	{
		bs.EraseR(e);
	}
	bs.InOrder();
}

int main()
{
	test2();

	return 0;
}
